package cloud.demo.controller;

import com.demo.springcloud.entity.Payment;
import com.demo.springcloud.entity.R;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author hxg
 * @version 1.0
 * @date 2022/1/14 18:18
 */
@RestController
public class paymentController {
    @Value("${server.port}")
    private String port;

    //模拟数据库
    public static HashMap<Long, Payment> hashMap = new HashMap<>();
    static
    {
        hashMap.put(1L,new Payment(1L,"28a8c1e3bc2742d8848569891fb42181"));
        hashMap.put(2L,new Payment(2L,"bba8c1e3bc2742d8848569891ac32182"));
        hashMap.put(3L,new Payment(3L,"6ua8c1e3bc2742d8848569891xt92183"));
    }

    @GetMapping("/payment/{id}")
    public R paymentTest(@PathVariable("id")Long id){
        Payment payment = hashMap.get(id);
        return new R(200,"payment"+port+id+"======"+payment);
    }
}
